import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const router = new Router({
  mode: 'hash',
  linkExactActiveClass: '',
  routes: [
    {
      path: '/',
      redirect: '/home',
      meta: { keepAlive: true, title: '核销' }
    },
    {
      path: '/home',
      name: 'home',
      redirect: 'home/untreated',
      meta: { keepAlive: false, title: '核销' },
      component: () => import('@/views/home/index'),
      children: [
        {
          path: 'untreated',
          name: 'untreated',
          meta: { keepAlive: false, title: '未处理' },
          component: () => import('@/views/untreated/index')
        },
        {
          path: 'consumed',
          name: 'consumed',
          meta: { keepAlive: false, title: '已核销' },
          component: () => import('@/views/consumed/index')
        }
      ]
    },
    {
      path: '/login',
      name: 'login',
      meta: { keepAlive: true, title: '登录' },
      component: () => import('@/views/login/index')
    },
    {
      path: '/balance',
      name: 'balance',
      meta: { keepAlive: false, title: '余额' },
      component: () => import('@/views/balance/index')
    },
    {
      path: '/detail/:id',
      name: 'detail',
      meta: { keepAlive: false, title: '详情' },
      component: () => import('@/views/detail/index')
    },
    {
      path: '*',
      name: 'notFound',
      meta: { keepAlive: false, title: '404' },
      component: () => import('@/views/notFound/index')
    }
  ],
  scrollBehavior: () => ({ y: 0 })
})
export default router
